package cn.iftrue.japidemo.advice;

import cn.iftrue.japidemo.common.ApiErrorCode;
import cn.iftrue.japidemo.common.ApiResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 异常统一处理
 *
 */
@ControllerAdvice
public class AppControllerAdvice {

	@ResponseBody
	@ExceptionHandler(value=Exception.class)
	public ApiResult exceptionHandler(Exception ex) {
		System.out.println(ex.getMessage());
		ApiResult apiResult= ApiResult.error(ApiErrorCode.A0500);
		return apiResult;
	}
}
